package com.uidt.project.ptsj.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.uidt.framework.aspectj.lang.annotation.Log;
import com.uidt.framework.aspectj.lang.enums.BusinessType;
import com.uidt.project.ptsj.domain.Officer;
import com.uidt.project.ptsj.service.IOfficerService;
import com.uidt.framework.web.controller.BaseController;
import com.uidt.framework.web.domain.AjaxResult;
import com.uidt.common.utils.poi.ExcelUtil;
import com.uidt.framework.web.page.TableDataInfo;

/**
 * 部门负责人信息Controller
 * 
 * @author uidt
 * @date 2024-08-12
 */
@RestController
@RequestMapping("/ptsj/officer")
public class OfficerController extends BaseController
{
    @Autowired
    private IOfficerService ptsjOfficerService;

    /**
     * 查询部门负责人信息列表
     */
    @PreAuthorize("@ss.hasPermi('ptsj:officer:list')")
    @GetMapping("/list")
    public TableDataInfo list(Officer ptsjOfficer)
    {
        startPage();
        List<Officer> list = ptsjOfficerService.selectOfficerList(ptsjOfficer);
        return getDataTable(list);
    }

    /**
     * 导出部门负责人信息列表
     */
    @PreAuthorize("@ss.hasPermi('ptsj:officer:export')")
    @Log(title = "部门负责人信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Officer ptsjOfficer)
    {
        List<Officer> list = ptsjOfficerService.selectOfficerList(ptsjOfficer);
        ExcelUtil<Officer> util = new ExcelUtil<Officer>(Officer.class);
        util.exportExcel(response, list, "部门负责人信息数据");
    }

    /**
     * 获取部门负责人信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ptsj:officer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ptsjOfficerService.selectOfficerById(id));
    }

    /**
     * 新增部门负责人信息
     */
    @PreAuthorize("@ss.hasPermi('ptsj:officer:add')")
    @Log(title = "部门负责人信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Officer ptsjOfficer)
    {
        return toAjax(ptsjOfficerService.insertOfficer(ptsjOfficer));
    }

    /**
     * 修改部门负责人信息
     */
    @PreAuthorize("@ss.hasPermi('ptsj:officer:edit')")
    @Log(title = "部门负责人信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Officer ptsjOfficer)
    {
        return toAjax(ptsjOfficerService.updateOfficer(ptsjOfficer));
    }

    /**
     * 删除部门负责人信息
     */
    @PreAuthorize("@ss.hasPermi('ptsj:officer:remove')")
    @Log(title = "部门负责人信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ptsjOfficerService.deleteOfficerByIds(ids));
    }
}
